package com.test.trans.service;

import com.test.trans.mapper.UserInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Transactional(propagation = Propagation.REQUIRED)
    public String registryUser(String userName,String password){
        if (userName == null || password == null){
            return "输入的用户名或密码异常，请重新输入";
        }
        int i = 10/0;
        userInfoMapper.insert(userName,password);
        return "注册成功";
    }

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public String registryUser2(String userName,String password){
        if (userName == null || password == null){
            return "输入的用户名或密码异常，请重新输入";
        }
        int i = 10/0;
        userInfoMapper.insert(userName,password);
        return "注册成功";
    }
}
